package cn.fzhui.dao;

import cn.fzhui.model.Admin;
import cn.fzhui.model.Model;
import cn.fzhui.util.DBUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class AdminDao implements Dao {

    @Override
    public Admin find(Model model) throws SQLException {
        Admin admin = (Admin) model;
        QueryRunner queryRunner = DBUtils.getQueryRunner();
        String sql = "SELECT * FROM admin WHERE username = '" + admin.getUsername() + "' AND password = '" + admin.getPassword() + "'";
        return queryRunner.query(sql, new BeanHandler<>(Admin.class));
    }

    @Override
    public int store(Model model) {
        return 0;
    }


}
